
cc.Class({
    extends: cc.Component,

    properties: {
        lock:cc.Node
    },

    onLoad(){
        this.id=parseInt(this.node.name.split('_')[1])-1
    },

    setOptions(options){
        this.id = options.id;
        this._x = options.x;
        this._y = options.y;
        this._a = options.a;
        this._b = options.b;
        this._angle = options.angle;
        this.topScale = 1;
        this.topOpacity = 255;
    },
    setTopScale(scale){
        this.topScale = scale
    },
    setTopOpacity(opacity){
        this.topOpacity = opacity
    },
    setAngle(angle){
        this.angle = angle;
        var a = angle*Math.PI/180
        var x = this._a*Math.cos(a)+this._x;
        var y = this._b*Math.sin(a)+this._y;
        this.node.x = x;
        this.node.y = y;
        var a = 0
        if(angle < 90){
            a = angle+90
        } else if(angle>270){
            a = angle-270
        }
        else {
            a = 270-angle
        }
        var b = (a)/180;
        this.node.scale = (1-b)*(1-this.topScale) + this.topScale
        this.node.opacity = (1-b)*(255-this.topOpacity) + this.topOpacity
    }
});
